
<%@include file="/WEB-INF/common/taglibs.jsp"%>
<script type="text/javascript"
	src="${ctx}/resources/js/datatable-query.js"></script>
<div class="row-fluid">
	<div class="span12">
		<div class="box gradient">
			<div class="title">
				<h4>
					<span>Individual</span>
				</h4>
				<a href="#" class="minimize">Minimize</a>
			</div>
			<div class="content clearfix scrollable">
				<table class="ajaxTable display table table-bordered">
					<thead>
						<tr>
							<th><a id="select_all"><span
									class="icomoon-icon-checkmark-2"></span></a></th>
							<th>Title</th>
							<th>SendTime</th>
							<th>Action</th>
						</tr>
					</thead>
				</table>
			</div>
		</div>
	</div>
	<a href="${ctx}/admin/mass-email/create/" class="btn btn-info">
		<span class="icon12 icomoon-icon-plus white"></span> New
	</a>
</div>


<script type="text/javascript">

var render = false;
var oTime = "";
var oTable;
$(document).ready(function () {
	oTable = $('.ajaxTable').dataTable({
		"bLengthChange": true,
		"aoColumnDefs": [
		  { 'bSortable': false, 'aTargets': [0,3] }
		],
		"sAjaxSource": '${ctx}/admin/mass-email/',
		"fnInitComplete": function (oSettings, json) { }
	});
	
	var name = $("<input>").attr({
		type : "text",
		field : "title",
		op : "cn",
		placeholder : "Title",
		class : "filterdata"
	});
	johnny.initTableQuery(name);

	$(".filterdata").keyup(function () {
		updateGrid();
	});
});
function updateGrid() {
	window.clearTimeout(oTime);
	oTime = setTimeout(function () { oTable.fnDraw(); }, 500);
}

var columnHeader = ['','title', 'deliverTime', ''];
var QueryData = function (aoData) {
	return johnny.initQueryData(aoData, columnHeader);
}

var DataTableForm = function (json, echo) {
	var dataArray = new Array();
	for (var i = 0; i < json.result.length; i++) {
		var subArray = new Array();
		var value = johnny.getForSelect(json.result[i].id);
 		subArray.push(value);
 		subArray.push(json.result[i].title);
		subArray.push(json.result[i].deliverTime);
		subArray.push(actionHtml(json.result[i].id));
		dataArray.push(subArray);
	}
	return {
		sEcho: echo,
		iTotalRecords: json.totalCount,
		iTotalDisplayRecords: json.totalCount,
		aaData: dataArray
	};
}
function actionHtml(id) {
return	johnny.getEditHtml("${ctx}/admin/mass-email/"+id+"/edit/");
}
</script>


<body>